QML Item属性Dump UI调试利器 您所在的位置:网站首页 qml delegate QML Item属性Dump UI调试利器

QML Item属性Dump UI调试利器

2022-12-28 21:56| 来源: 网络整理| 查看: 265

简述

调试UI经常需要打印组件属性,尤其是没上手过的组件,对内部工作机制不了解,导致显示效果达不到目标。所以有一个实时显示Object属性的组件就很方便。效果如下: 在这里插入图片描述

实现代码 import QtQuick import QtQml ListView { id: root property string title property var target property var properties: [] property color titleColor: "black" property color textColor: "black" implicitWidth: contentWidth implicitHeight: contentHeight // clip: true header: Rectangle{ width: root.implicitWidth height: titleText.implicitHeight Text{ id: titleText color: titleColor text: root.title font.bold: true } } model: properties delegate: Text{ color: textColor text: modelData + " : " + target[modelData] } } 使用代码 ...省略 Column{ anchors.fill: parent anchors.margins: 6 spacing: 10 PropertyDump{ title: "Root&Flickable" target: root properties: ["x","y","width","height", "contentWidth","contentHeight", "scaleCenterX","scaleCenterY","imgScale"] } PropertyDump{ title: "Image" target: currentImage properties: ["x","y","width","height","scale"] } PropertyDump{ title: "MouseArea" target: mouseArea properties: ["mouseX","mouseY"] } }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有